$(document).ready(function () {

    $(".right_bottom a").click(function () {
        var search = $(this).text();
        $("#queryKeysStr").val(search);
    });

    $(".spinner button").click(function () {
        var price = $("#productprice").val();
        var c = $("#goodsPriceSum").val();
        $(".span3 font").text("￥" + parseInt(price) * parseInt(c));
    });

    $(".buttom2 .right").click(function () {

        var count = $("#goodsPriceSum").val();
        var productID = $("#productID").val();
        var username = $("#top_user_login_tag").val();

        if (username == null) {
            alert("请先登录！");
        } else {
            $.ajax({
                url: "/addOrder",// 跳转到 action
                data: {
                    count: count,
                    productID: productID,
                    username: username,
                },
                type: "post",
                cache: false,
                dataType: "text",
                success: function (data) {
                    if ("成功" == data) {
                        alert("已加入购物车！");
                        window.location.reload();
                    } else {
                        alert("加入购物车失败！");
                        window.location.reload();
                    }
                },
                error: function () {
                    alert("加入购物车异常！");
                }
            });
        }
    });
});